<?php
/**
 * Created by PhpStorm
 * User: Jhinwy
 * Date: 6/4/24
 * Time: 11:10 AM
 */


namespace App\Http\Controllers\Admin;


use App\Services\UserService;
use Illuminate\Http\Request;
use App\Http\Controllers\ResourceController;

class UserController extends ResourceController
{
    protected $service;

    public function __construct(UserService $service)
    {
        $this->service = $service;
    }
    /**
     * 获取部门成员列表
     *
     * @param Request $request
     * @return mixed
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public function getUserList(Request $request)
    {
        return $this->responseWithSuccess($this->service->getUserList($request->post()));
    }


    public function getAll()
    {
        return $this->responseWithSuccess($this->service->getAll());
    }



    /**
     * 创建部门
     *
     * @param Request $request
     * @return mixed
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public function createUser(Request $request)
    {
        return $this->service->createUser($request->post()) ?
            $this->responseWithSuccess() : $this->responseWithError();
    }


    /**
     * 删除成员
     *
     * @param Request $request
     * @return mixed
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public function delUser(Request $request)
    {
        return $this->service->delUser($request->post()) ?
            $this->responseWithSuccess() : $this->responseWithError();
    }


    /**
     * 分配用户类型
     *
     * @param Request $request
     * @return mixed
     */
    public function assignUserCategory(Request $request)
    {
        return $this->service->assignUserCategory($request->post()) ?
            $this->responseWithSuccess() : $this->responseWithError();
    }


    /**
     * 分配用户运营
     *
     * @param Request $request
     * @return mixed
     */
    public function assignUserAdmin(Request $request)
    {
        return $this->service->assignUserAdmin($request->post()) ?
            $this->responseWithSuccess() : $this->responseWithError();
    }


    /**
     * 获取账号池
     *
     * @return mixed
     */
    public function getUserPool()
    {
        return $this->responseWithSuccess($this->service->getUserPool());
    }
}
